package com.cj.exception;

/**
 * 错误码枚举
 */
public enum ErrorCode {
    // 系统错误
    SYSTEM_ERROR(100, "系统错误"),
    DATABASE_ERROR(101, "数据库错误"),
    // 参数错误
    PARAM_ERROR(200, "参数错误"),
    PARAM_REQUIRED(201, "参数缺失"),
    PARAM_INVALID(202, "参数无效"),
    // 业务错误
    BUSINESS_ERROR(300, "业务错误"),
    USER_EXISTS(301, "用户已存在"),
    USER_NOT_FOUND(302, "用户不存在"),
    USER_HAS_RELATED_DATA(303, "用户存在关联数据，无法删除"),
    // 权限错误
    AUTH_ERROR(400, "认证错误"),
    AUTH_REQUIRED(401, "请先登录"),
    AUTH_FORBIDDEN(402, "无权访问");

    private final int code;
    private final String message;

    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
